package com.oa.desktop.news.news_label.service;

import com.oa.commons.beans.NewsLabel;
import com.oa.commons.ov.Page;
import com.oa.desktop.news.news_label.dao.INewsLabelDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class INewsLabelServiceImpl implements INewsLabelService {
    @Autowired
    private INewsLabelDao newsLabelDao;
    @Override
    public Page<NewsLabel> findCurrPage(int pageNum) {
        Page<NewsLabel> page = new Page();
        int count = newsLabelDao.selectAllNewsLabelCount();
        page.setPageNum(pageNum);
        page.setTotalRows(count);
        List<NewsLabel> list = newsLabelDao.selectAllNewsLabel(page);
        page.setDatas(list);
        return page;
    }

    @Override
    public List<NewsLabel> findNewsLabel() {
        List<NewsLabel> list = newsLabelDao.findAllNewsLabel();
        return list;
    }

    @Override
    public void deleteNewsLabel(int id) {
        newsLabelDao.deleteNewsLabel(id);
    }

    @Override
    public void addNewsLabel(NewsLabel newsLabel) {
        newsLabelDao.addNewsLabel(newsLabel);
    }

    @Override
    public List<NewsLabel> findNewsLabelById(int id) {
        List<NewsLabel> list = newsLabelDao.findNewsLabelById(id);
        return list;
    }

    @Override
    public void updateNewsLabel(NewsLabel newsLabel,int id) {
        newsLabelDao.updateNewsLabel(newsLabel,id);
    }

    @Override
    public Page<NewsLabel> findCurrPageChildren(int id, int pageNum) {
        Page<NewsLabel> page = new Page();
        int count = newsLabelDao.selectNewsLabelCount(id);
        page.setPageNum(pageNum);
        page.setTotalRows(count);
        List<NewsLabel> list = newsLabelDao.selectNewsLabel(page,id);
        page.setDatas(list);
        return page;
    }
}
